import React, { useState } from 'react'

// 【点击按钮】开始倒计时
// 问题：重复点击会开启多个定时器
export default function App() {
  const [count, setCount] = useState(10)

  const handleClick = () => {
    setInterval(() => {
      // 注意这儿一定是函数的形式
      setCount((count) => count - 1)
    }, 1000)
  }
  return (
    <div>
      <h3>{count}</h3>
      <button onClick={handleClick}>开始倒计时</button>
    </div>
  )
}
